package _021_10_3

func lengthOfLastWord(s string) int {
	wId := len(s) - 1

	for i := len(s) - 1; i >= 0; i-- {
		if s[i] != ' ' {
			wId = i
			break
		}
	}

	if wId == 0 {
		return 1
	}

	for i := wId; i >= 0; i-- {
		if s[i] == ' ' {
			return wId - i
		}
	}
	return wId + 1
}
